<script setup>
import { ref } from 'vue'
import * as iconList from '@element-plus/icons-vue'

const icons = ref([
  'AddLocation',
  'Aim',
  'AlarmClock',
  'Apple',
  'ArrowDown',
  'ArrowDownBold',
  'ArrowLeft',
  'ArrowLeftBold',
  'ArrowRight',
  'ArrowRightBold',
  'ArrowUp',
  'ArrowUpBold',
  'Avatar',
  'Back',
  'ZoomOut'
])
defineProps({
  modelValue: String
})

const emit = defineEmits(['update:modelValue'])
const onChange = (icon) => {
  emit('update:modelValue', icon)
}
</script>

<template>
  <div class="flex items-center">
    <el-icon :size="20" class="mr-3" v-if="modelValue">
      <component :is="modelValue"></component>
    </el-icon>
    <el-select filterable :modelValue="modelValue" placeholder="请选择图标" @change="onChange">
      <el-option v-for="item in icons" :key="item" :label="item" :value="item">
        <div class="flex items-center justify-between">
          <el-icon>
            <component :is="item"></component>
          </el-icon>
          <span class="text-[#1da1f2]">{{ item }}</span>
        </div>
      </el-option>
    </el-select>
  </div>
</template>
